<?php

namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Brick\Math\RoundingMode;

class AppleTreeResource extends JsonResource
{
    public function toArray($request)
    {
    	$data = $this->resource;

    	$user = request()->user();
    	
        return [
	        'id' 				=> (int)$data->id,
	        'title'    => $data->title,
	        'apple_tree_period'    => $data->apple_tree_period,
	        'consume_apples'    => $data->consume_apples,
	        'produce_apples'    => $user->is_stop ? 0 :  $data->produce_apples,
	        'buy_limit'    => $data->buy_limit,
	        'image' =>img_path($data->image)
        ];
    }
}
